package vip.xiaonuo.facedoor.modular.appversion.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.facedoor.modular.appversion.param.AppUpdateQuery;
import vip.xiaonuo.facedoor.modular.appversion.service.AppUpdateService;
import vip.xiaonuo.facedoor.modular.deviceoperation.param.AppUploadParam;
import vip.xiaonuo.facedoor.modular.deviceoperation.service.AppFileService;

import javax.annotation.Resource;

@RestController
public class AppController {

    @Resource
    private AppUpdateService updateService;

    @Resource
    private AppFileService fileService;

    @PostMapping("/app/update")
    @BusinessLog(title = "APP上传版本更新", opType = LogAnnotionOpTypeEnum.OTHER)
    public ResponseData checkUpdate(@RequestBody @Validated AppUpdateQuery update){
        return new SuccessResponseData(updateService.checkUpdate(update));
    }


    @PostMapping("/app/upload")
    @BusinessLog(title = "文件信息表_APP上传文件", opType = LogAnnotionOpTypeEnum.OTHER)
    public ResponseData fileUpload(AppUploadParam param){
        fileService.uploadFile(param);
        return new SuccessResponseData();
    }

}
